package dukeAll;

import java.util.Arrays;

public class OlympicCandles {
  public int numberOfNights(int[] candles) {   
  int days;
  
  Arrays.sort(candles);    
    label:for(days = 0; days < candles.length; days++) {
    for(int i = candles.length-1; i >= candles.length-1-days; i--) {
      candles[i]--;
      if(candles[i] < 0)
      break label;
    }
    Arrays.sort(candles);
    }
    return days;
  }
}